package me.bincker.formwork.web.core.service

import org.springframework.data.domain.Example
import org.springframework.data.domain.Page
import org.springframework.data.domain.Pageable
import org.springframework.data.domain.Sort
import java.util.*

interface IBaseService<T> {
    fun findAll(pageable: Pageable): Page<T>
    fun findAll(): MutableList<T>
    fun findAll(sort: Sort): MutableList<T>
    fun findAllById(ids: Iterable<String>): MutableList<T>
    fun <S : T> saveAll(entities: Iterable<S>): MutableList<S>
    fun deleteInBatch(entities: Iterable<T>)
    fun deleteAllInBatch()
    fun getOne(id: String?): T
    fun <S : T> findAll(example: Example<S>): MutableList<S>
    fun <S : T> findAll(example: Example<S>, sort: Sort): MutableList<S>
    fun <S : T> save(entity: S): S
    fun findById(id: String?): T?
    fun existsById(id: String): Boolean
    fun count(): Long
    fun deleteById(id: String)
    fun delete(entity: T)
    fun deleteAll(entities: Iterable<T>)
    fun deleteAll()
    fun <S : T> findOne(example: Example<S>): S?
    fun <S : T> findAll(example: Example<S>, pageable: Pageable): Page<S>
    fun <S : T> count(example: Example<S>): Long
    fun <S : T> exists(example: Example<S>): Boolean
}